home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / e-tools / plugins / frumsplugs / examples / testplugins.e < prev    next >
Encoding:
Text File  |  1992-09-02  |  4.7 KB  |  137 lines

  1. /* Program to test all frumSPlugs plugins */
  2. -> $VER: TestPlugins.e V1.0 Stephen Sinclair (96.06.16)
  3.  
  4. OPT OSVERSION=37
  5. MODULE 'Tools/EasyGUI','Plugins/BackDrop','Plugins/BitMap','Plugins/Gauge',
  6.        'Plugins/BusyBox','Plugins/Image','Plugins/ImageButton'
  7. MODULE 'Intuition/Intuition','Utility','Graphics/Gfx','Intuition/Screens'
  8.  
  9. DEF bdp:PTR TO backdropplugin,
  10.     bp:PTR TO bitmapplugin,
  11.     gp:PTR TO gaugeplugin,
  12.     bbp:PTR TO busyboxplugin,
  13.     ip:PTR TO imageplugin,
  14.     ibp:PTR TO imagebuttonplugin
  15. DEF bmp1:PTR TO bitmap,bmp2:PTR TO bitmap,scr:PTR TO screen
  16.  
  17. PROC main() HANDLE
  18. /* Must open utility.library for imagebutton. */
  19.   IF (utilitybase:=OpenLibrary('utility.library',0))=NIL THEN Raise("UTIL")
  20.  
  21. /* Allocate bitmaps to use for backdrop, bitmap, image, and imagebutton */
  22.   IF (bmp1:=AllocBitMap(32,32,3,BMF_CLEAR,NIL))=NIL THEN Raise("MEM")
  23.   IF (bmp2:=AllocBitMap(25,28,1,0,NIL))=NIL THEN Raise("MEM")
  24.  
  25. /* This is much better on a MagicWB screen, but if the user runs it on */
  26. /* a regular 4 colour screen, we may as well try our best to make it   */
  27. /* look good.                                                          */
  28.   scr:=LockPubScreen(NIL)
  29.   IF scr
  30.     IF scr.bitmap.depth<=2
  31.       easygui('Warning!',
  32.         [ROWS,
  33.           [BAR],
  34.           [TEXT,'You really should run this',NIL,FALSE,STRLEN],
  35.           [TEXT,'on an 8 colour screen with',NIL,FALSE,STRLEN],
  36.           [TEXT,'the MagicWB colours.  It',NIL,FALSE,STRLEN],
  37.           [TEXT,'looks a lot nicer that way.',NIL,FALSE,STRLEN],
  38.           [BAR],
  39.           [BUTTON,0,'I''ll remember that...']
  40.         ],0,scr)
  41. /* For four colour screens, make the backdrop blue. */
  42.       CopyMem({backdrop},bmp1.planes[0],128)
  43.       CopyMem({backdrop},bmp1.planes[1],128)
  44.     ELSE
  45. /* For a MagicWB screen, make it light gray. */
  46.       CopyMem({backdrop},bmp1.planes[0],128)
  47.       CopyMem({backdrop},bmp1.planes[2],128)
  48.     ENDIF
  49.   ENDIF
  50.  
  51.   CopyMem({alien},bmp2.planes[0],112)
  52.  
  53. /* And now for the EasyGUI magic! */
  54.   easygui('frumSPlugs',
  55.     [ROWS,
  56.       [PLUGIN,0,NEW bdp.backdropplugin(bmp1,0,0,32,32)],
  57.       [TEXT,'BackDrop: (All over)',NIL,FALSE,5],
  58.       [BEVEL,[ROWS,
  59.         [COLS,
  60.           [ROWS,
  61.             [TEXT,'BitMap:',NIL,FALSE,5],
  62.             [BEVELR,[PLUGIN,0,NEW bp.bitmapplugin(bmp2,0,0,25,28,$30)]]
  63.           ],
  64.           [BAR],
  65.           [ROWS,
  66.             [TEXT,'Gauge:',NIL,FALSE,5],
  67.             [PLUGIN,0,NEW gp.gaugeplugin(100,0)]
  68.           ]
  69.         ],
  70.         [BAR],
  71.         [COLS,
  72.           [ROWS,
  73.             [TEXT,'BusyBox:',NIL,FALSE,5],
  74.             [PLUGIN,0,NEW bbp.busyboxplugin([1,2,3,4,5,6,7]:INT,BEVELR,RESIZEX)]
  75.           ],
  76.           [BAR],
  77.           [ROWS,
  78.             [TEXT,'Image:',NIL,FALSE,5],
  79.             [BEVELR,[PLUGIN,0,NEW ip.imageplugin([0,0,25,28,1,bmp2.planes[0],1,6,NIL]:image)]]
  80.           ],
  81.           [BAR],
  82.           [ROWS,
  83.             [TEXT,'ImageButton:  (Click Me!)',NIL,FALSE,5],
  84.             [PLUGIN,{dostuff},NEW ibp.imagebuttonplugin([0,0,25,28,1,bmp2.planes[0],1,0,NIL]:image,
  85.                                                         [0,0,25,28,1,bmp2.planes[0],1,2,NIL]:image)]
  86.           ]
  87.         ]
  88.       ]],
  89.       [BUTTON,0,'Okay']
  90.     ])
  91. EXCEPT DO
  92. /* ALWAYS END imagebuttons and busyboxes. */
  93.   END ibp,bbp
  94.   IF utilitybase THEN CloseLibrary(utilitybase)
  95.   IF bmp1 THEN FreeBitMap(bmp1)
  96.   IF bmp2 THEN FreeBitMap(bmp2)
  97.   SELECT exception
  98.     CASE "UTIL"; WriteF('Could not open utility.library.\n')
  99.     CASE "MEM" ; WriteF('Not enough mem.\n')
  100.     DEFAULT; IF exception>0 THEN WriteF('Exception: \s\n',[exception,0])
  101.   ENDSELECT
  102. ENDPROC
  103.  
  104. CHAR '$VER: TestPlugins V1.0 Stephen Sinclair (95.06.16)',0
  105.  
  106. /* The bitplane data */
  107. backdrop:
  108. /* 32 x 32 x 1 */
  109. INT $0000,$0000,$7FFF,$FFFE,$4000,$0002,$4000,$0002,$4000,$0002,$4000,$0002,
  110.     $43FF,$FFC2,$4200,$0042,$4200,$0042,$427F,$FE42,$4240,$0242,$4240,$0242,
  111.     $4240,$0242,$4240,$0242,$4243,$FE42,$4242,$0042,$4242,$0042,$4242,$7FC2,
  112.     $4242,$4002,$4242,$4002,$4242,$4002,$4242,$4002,$4242,$7FFE,$4242,$0000,
  113.     $4242,$0000,$C243,$FFFF,$0240,$0000,$0240,$0000,$0240,$0000,$0240,$0000,
  114.     $FE7F,$FFFF,$0000,$0000,$0042
  115.  
  116. alien:
  117. /* 25 x 28 x 1 */
  118. INT $0000,$0000,$007F,$0000,$03FF,$E000,$0FFF,$F800,$1FFF,$FC00,$1FFF,$FE00,
  119.     $3FFF,$FE00,$7FFF,$FF00,$7FFF,$FF00,$7FFF,$FF00,$47FF,$F100,$41FF,$C100,
  120.     $607F,$0300,$203E,$0200,$301C,$0600,$381C,$0E00,$1E08,$3C00,$1F88,$FC00,
  121.     $0FFF,$F800,$0FFF,$F800,$07FF,$F000,$03FF,$E000,$03FF,$E000,$01FF,$C000,
  122.     $00FF,$8000,$007F,$0000,$003E,$0000,$0000,$0000,$0600
  123.  
  124. /* Procedure to demonstrate the gauge and the busybox at the same time */
  125. PROC dostuff(x)
  126.   DEF inc
  127.   IF gp.cv>50 THEN inc:=-1 ELSE inc:=1
  128.   bbp.on(TRUE)
  129.   FOR x:=1 TO 100
  130.     gp.addgauge(inc)
  131.     Delay(1)  -> needs a delay - otherwise it's too fast to see
  132.   ENDFOR
  133.   bbp.on(FALSE)
  134. ENDPROC
  135.  
  136. /* That's it!  It's that simple to use frumSPlugs! */
  137.